// TOWN SCRIPT
//    Town 4: Small town

// This is the special encounter script for this town.
// The states INIT_STATE, EXIT_STATE, and START_STATE have
// meanings that are described in the documenation. States you write
// yourself should be numbered from 10-100.

begintownscript;

variables;

short i,j,k,r1,choice;

body;

beginstate INIT_STATE;
	change_blocked(14,12,1);
	change_blocked(15,12,1);
	change_blocked(16,12,1);
	change_blocked(17,12,1);
	
	change_blocked(10,15,1);
	change_blocked(11,15,1);
	change_blocked(12,15,1);
	change_blocked(13,15,1);
	
	change_blocked(11,10,1);
break;

beginstate EXIT_STATE;
// Always called when the town is left.
break;

beginstate START_STATE;
// This state is called every turn the party is in this town.
break;

beginstate 10;
	block_entry(1);
		move_to_new_town(5,8,8);
		end();
break;

beginstate 11;
	if (get_flag(2,3) == 250)
		end();
	reset_dialog();
	add_dialog_str(0,"4.",0);
	add_dialog_str(1,"You are in a small town. Point B is in front of you. The direct route to Point B is obstructed. You must first reach Point A to activate Point B. A hostile monster blocks the route to Point B. You must reach Point B.",0);
	add_dialog_choice(0,"OK.");
	choice = run_dialog(1);
	set_flag(2,3,250);
break;

beginstate 12;
	if (get_flag(1,2) >= 1)
		end();
		
	message_dialog("You have yet to activate Point B.","");
	block_entry(1);
break;

beginstate 15;
	print_str("You activate Point B.");
	set_flag(1,2,1);
break;

beginstate 18;
	set_flag(1,2,0);
	set_state_continue(10);
break;

beginstate 19;
	if (get_flag(1,5) == 250)
		end();
	set_flag(1,5,250);
	message_dialog("The hostile monster appears.","");
	activate_hidden_group(5);
break;

